package pers.zcr.meringue.monolithic.demo.testuser.web;

import cn.hutool.core.bean.BeanUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.zcr.meringue.monolithic.demo.testuser.domain.dto.TestUserDetailQry;
import pers.zcr.meringue.monolithic.demo.testuser.domain.dto.vo.TestUserVo;
import pers.zcr.meringue.monolithic.demo.testuser.service.ITestUserService;
import pers.zcr.meringue.monolithic.demo.testuser.web.dtoadapter.vo.TestUserVoAdapter;

@RestController
@RequestMapping("/test/user")
@Tag(name = "用户测试控制器")
public class TestUserController {
    private final ITestUserService testUserService;

    public TestUserController(ITestUserService testUserService) {
        this.testUserService = testUserService;
    }

    @GetMapping("/{id}")
    @Operation(summary = "根据ID获取用户信息", description = "根据提供的ID获取对应的用户信息")
    public TestUserVoAdapter getUser(@PathVariable Long id) {
        TestUserDetailQry testUserDetailQry = new TestUserDetailQry();
        testUserDetailQry.setId(id);
        TestUserVo testUserVo = testUserService.queryById(testUserDetailQry);
        return BeanUtil.copyProperties(testUserVo, TestUserVoAdapter.class);
    }
}
